import { HostEnum, type CategoryItemType, type GameJson } from "~/utils";
import { getServerCache } from "../plugins/cache";

/** 获取对应数量的分类列表 */
export default defineEventHandler(async (event): Promise<CategoryItemType[]> => {
  const { hostName = HostEnum.localhost, count = 10 } = await readBody(event);
  const { categoryJson = [] } = getServerCache().gameJsonDataSource[hostName];
  return categoryJson.slice(0, count);
});
